package com.project.controller;

import com.project.bean.UserBean;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("user")
public class UserController {

    @RequestMapping("land")
    public String login(@RequestParam("name") String userName, String pwd,
                        UserBean user){
        System.out.println(userName+"    "+pwd+"    "+user);
        if("刘三".equals(userName) && "123".equals(pwd)){
            return "登陆成功";
        }
        else{
            return "登陆失败";
        }
    }


    @RequestMapping(value = "add",method = RequestMethod.POST)
    public String add(UserBean user){
        System.out.println(user);
        return "添加成功";
    }

    @RequestMapping("del/{userId}")
    public String del(@PathVariable("userId") int id){

        return "删除编号："+id;
    }

    @RequestMapping("/update")
    public String update(@RequestParam(value = "id",defaultValue = "0") int id,
                         HttpServletRequest request, HttpServletResponse response){

        return "<span style='color:red'>修改</span>"+id;
    }
}
